package com.xyl.coap;

import org.eclipse.californium.core.CoapResource;
import org.eclipse.californium.core.CoapServer;
import org.eclipse.californium.core.server.resources.CoapExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class CoapConfig {

    @Bean
    public CoapServer coapServer() {
        CoapServer server = new CoapServer();
        server.add(new CoapResource("example") {
            @Override
            public void handleGET(CoapExchange exchange) {
                exchange.respond("Hello, CoAP!");
            }
        });
        return server;
    }


}